/**
 * Created by Ysssssss on 20/12/21.
 */

export function debounce (func, wait) {
    let timer;

    return function () {
        clearTimeout(timer);
        timer = setTimeout(func, wait);
    };
};

export function throttle (func, wait) {
    let last = 0;
    return function () {
        const current_time = +new Date();
        if (current_time - last > wait) {
            func.apply(this, arguments);
            last = +new Date();
        }
    };
};